Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drop is-ip by representing IPs internally as octets #214

Merged
merged 6 commits into from
Nov 8, 2022

Conversation

dapplion
Copy link
Contributor

Current implementation coverts IPs from string and bytes multiple times unnecessarily. This motivated the need for is-ip and ip6addr libraries.

This PR:

  • Represents PONG message IP:port combo as bytes internally
  • Tally votes without multiaddr representation

@wemeetagain wemeetagain marked this pull request as ready for review November 4, 2022 20:00
@wemeetagain wemeetagain requested a review from a team as a code owner November 4, 2022 20:00
@wemeetagain wemeetagain changed the title Drop is-ip by representing IPs internally as octets fix: drop is-ip by representing IPs internally as octets Nov 4, 2022
@wemeetagain
Copy link
Member

@dapplion @tuyennhv ready for review

@wemeetagain
Copy link
Member

this PR would be a lot nicer with a better name for the IPUDP type...

@wemeetagain wemeetagain changed the title fix: drop is-ip by representing IPs internally as octets feat: drop is-ip by representing IPs internally as octets Nov 4, 2022
src/util/ip.ts Outdated Show resolved Hide resolved
throw new Error("invalid port for encoding");
}
return Buffer.concat([
Buffer.from([MessageType.PONG]),
RLP.encode([toBuffer(m.id), toBuffer(m.enrSeq), tuple, m.recipientPort]),
RLP.encode([
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to force prettier into placing the arguments vertically

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, we should include this in the next version of lodestar

@wemeetagain wemeetagain merged commit 6c43151 into master Nov 8, 2022
@wemeetagain wemeetagain deleted the dapplion/drop-is-ip branch November 8, 2022 14:33
@philknows
Copy link
Member

philknows commented Nov 8, 2022

For whoever is creating the PR to bump Lodestar to discv5 1.4.0, can you additionally add Lodestar v1.3.0 milestone to it as well? Thanks!

// 4 32 ip4
// 41 128 ip6
// 273 16 udp
const Protocol = {
Copy link
Contributor Author

@dapplion dapplion Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the issue with using an enum here? 6 is much less descriptive than ip6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its used to simplify multiaddrFromSocketAddress. PR welcome if it bothers you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants